package chapter12.casePage

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/20 19:55
  * @history:
  *          1.2019/1/20 created by chuhaitao
  */
object CaseClassDemo {


  def main(args: Array[String]): Unit = {

    for (amt <- Array(Dollar(1212), Currency(1213, "type"), NoAount)) {
      amt match {
        case Dollar(n) => println("n=" + n)
        case Currency(n, m) => println("n=" + n + ";m=" + m)
        case NoAount => println("null")
        case _ => println("_")
      }
    }
    //copy


    val currency = new Currency(30000, "RMB")
    //创建的对象currency2的属性值和currency一样
    val currency2 = currency.copy()

    println(currency2)

  }
}


abstract class Amount

case class Dollar(vallue: Double) extends Amount

case class Currency(vallue: Double, unit: String) extends Amount

case object NoAount extends Amount

class A(vallue: Double)